home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10813 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: cleveland.Freenet.Edu!ah739
  2. From: ah739@cleveland.Freenet.Edu (Leslie J. Somos)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Quotes in C comments
  5. Date: 20 Mar 1996 07:00:19 GMT
  6. Organization: Case Western Reserve University, Cleveland, OH (USA)
  7. Message-ID: <4ioae3$bis@madeline.INS.CWRU.Edu>
  8. References: <Do6nn5.5rE@oscar.prima.ruhr.de>
  9. Reply-To: ah739@cleveland.Freenet.Edu (Leslie J. Somos)
  10. NNTP-Posting-Host: piglet.ins.cwru.edu
  11.  
  12.  
  13. In a previous article, patrick@oscar.prima.ruhr.de (Patrick Mau) says:
  14.  
  15. >Hi there,
  16. >
  17. >I had a really funny problem with quotes in C programs:
  18. >
  19. >The question is:
  20. > How should a compiler handle the following comments
  21. >
  22. >First Example:
  23. >
  24. >/*
  25. > *  printf( "/* funny printf */" );
  26. > *                           ^^--- Point A
  27. > */
  28. >
  29. >Second Example:
  30. >
  31. > /*
  32. >  *  You can't do xyz here
  33. >  *         ^--- Point B
  34. >  */
  35. >
  36. >In the first example the compiler could stop at point A thinking the
  37. >comment ends at that point. This would be the case if the compiler
  38. >doesn't check quotes within comments. ( they are usually ignored. )
  39. >
  40. >In the second example ( _that_ happened to me with gcc 2.7.2 )
  41. >the compiler complains about an unterminated character constant
  42. >at EOF and says it could be at point B.
  43. >
  44. >How should a good compiler handle those kinds of comments.
  45.  
  46. A good compiler should handle it as the C language specification
  47. says it should.  (I don't know offhand.)
  48.  
  49. But more important immediately to you, is how is it handled by
  50. the particular compiler that you are required to use.
  51.  
  52.  
  53. >Should it check for quotes within comments or not ?
  54. >
  55. >        Best regards ...
  56. >             ... Patrick
  57. >
  58.  
  59.  
  60. A suggestion:
  61.  
  62. printf("%s%s%s", "/", "* a bulletproof printf *", "/");
  63.  
  64. --
  65.